<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>重复请求</title>
</head>
<body>
<button>发送请求</button>
<script>
    const btn = document.getElementsByTagName("button")[0];
    let isSending = false;
    let xhr = null;
    btn.addEventListener('click', function () {
        if (isSending) {
            xhr.abort();
        }
        isSending = true;
        xhr = new XMLHttpRequest();
        xhr.open('GET', 'http://localhost:8080/net-work-time-out')
        xhr.send();
        xhr.onreadystatechange = function () {
            if (xhr.readyState === 4) {
                isSending = false;
            }
        }
    });
</script>
</body>
</html>